package com.moji.controller.web;


import com.moji.common.base.ApiResult;
import com.moji.common.entity.MyPage;
import com.moji.entity.MjBanner;
import com.moji.entity.MjSupportHelp;
import com.moji.entity.UploadFiles;
import com.moji.entity.vo.CommonIndexDTO;
import com.moji.service.MjBannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Banner(MjBanner)表控制层
 *
 * @author makejava
 * @since 2024-07-21 14:34:56
 */
@RestController
@RequestMapping("web/mjBanner")
@Api(tags = "Banner相关web接口", value = "Banner相关web接口")
public class MjBannerController {
    /**
     * 服务对象
     */
    @Resource
    private MjBannerService mjBannerService;


    /**
     * 查询Banner数据
     *
     * @param
     * @return
     */
    @PostMapping("/queryByPage")
    @ApiOperation(value = "全部banner - 分页查询(只需要传入分页参数)", response = MyPage.class)
    public ApiResult<MyPage<MjBanner>> queryByPage(@RequestBody CommonIndexDTO commonIndexDTO) {
        MyPage<MjBanner> mjBannerMyPage = mjBannerService.queryByPage(commonIndexDTO);
        return ApiResult.ok(mjBannerMyPage);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @PostMapping("/detail")
    @ApiOperation(value = "根据id查看Banner详情",response = MjBanner.class)
    public ApiResult<MjBanner> queryById(@RequestParam("id") Long id) {
        return ApiResult.ok(this.mjBannerService.queryById(id));
    }

}

